<?php
/**
 * 调试助手
 *
 * @copyright  Copyright (c) 2006 - 2010 Movoin Studio <http://www.movoin.com>
 * @license    GNU General Public License 2.0 {@link http://www.gnu.org/licenses/gpl-2.0.html}
 * @package    Helper
 * @category   Moca
 * @author     Allen <movoin@gmail.com>
 * @version    $Id: Debug.php 4 2010-06-02 03:08:52Z movoin $
 **/

class Moca_Helper_Debug
{
    /**
     * 输出变量的内容，通常用于调试
     *
     * @param mixed $vars 要输出的变量
     * @param string $label
     * @param boolean $return
     */
    function dump($vars, $label = '', $return = false)
    {
        if (ini_get('html_errors')) {
            $content = "<pre>\n";
            if ($label != '') {
                $content .= "<strong>{$label} :</strong>\n";
            }
            $content .= htmlspecialchars(print_r($vars, true));
            $content .= "\n</pre>\n";
        } else {
            $content = $label . " :\n" . print_r($vars, true);
        }
        if ($return) { return $content; }
        echo $content;
        return null;
    }
}

/**
 * Moca_Helper_Debug::dump() 的简写
 */
function dump($vars, $label = '', $return = false)
{
    Moca_Helper_Debug::dump($vars, $label, $return);
}

